# -*- coding: utf-8 -*-

# Scrapy settings for JDCooker project
#
# For simplicity, this file contains only settings considered important or
# commonly used. You can find more settings consulting the documentation:
#
#     https://doc.scrapy.org/en/latest/topics/settings.html
#     https://doc.scrapy.org/en/latest/topics/downloader-middleware.html
#     https://doc.scrapy.org/en/latest/topics/spider-middleware.html

BOT_NAME = 'JDCooker'

SPIDER_MODULES = ['JDCooker.spiders']
NEWSPIDER_MODULE = 'JDCooker.spiders'

# Crawl responsibly by identifying yourself (and your website) on the user-agent
# USER_AGENT = 'JDCooker (+http://www.yourdomain.com)'

# Obey robots.txt rules
ROBOTSTXT_OBEY = True

# Configure maximum concurrent requests performed by Scrapy (default: 16)
# CONCURRENT_REQUESTS = 32

# Configure a delay for requests for the same website (default: 0)
# See https://doc.scrapy.org/en/latest/topics/settings.html#download-delay
# See also autothrottle settings and docs
# DOWNLOAD_DELAY = 3
# The download delay setting will honor only one of:
# CONCURRENT_REQUESTS_PER_DOMAIN = 16
# CONCURRENT_REQUESTS_PER_IP = 16

# Disable cookies (enabled by default)
# COOKIES_ENABLED = False

# Disable Telnet Console (enabled by default)
# TELNETCONSOLE_ENABLED = False

# Override the default request headers:
DEFAULT_REQUEST_HEADERS = {
    "User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Mobile Safari/537.36",
    "x-requested-with": "XMLHttpRequest",
    "cookie:": "__jdu=1271793754; shshshfpa=667de232-4787-0be7-d720-dff9d7620d66-1533953518; shshshfpb=06252e29a4b1d2885298f3e0c712c4b09816609820f70580d5b6e45ee7; TrackID=1Bh-FjCL0k02rh5LPw6d9yyEqjA7HuZzsvMmU5Q1zx7NaMagUikHNVajTxLspFzftogPKHgTeSVGx0OhrPpFFZIDP5qA49EcLZ4QQkOZTByW2YWHcVgGv78Tmb21iq36J; pinId=W6Yl5G64gVb8GY_ZW48_nA; __jdc=122270672; mt_xid=V2_52007VwMRVF1eWlgZTRxsA2ULRlNdWAJGTE9MDhliUxJQQVBaUkxVS1wHYAYXVFleW19LeRpdBW4fElNBWVVLH0kSWQVsBhBiX2hRahxIH1QAYjMRVV1e; PCSYCityID=1213; ipLoc-djd=1-72-2799-0; unpl=V2_ZzNtbURRFEcnWBMBKEwPVmJTFVoRVUIRfVhABysYVQUzVEEOclRCFXwURlVnGFUUZwcZXkRcQRVFCHZXchBYAWcCGllyBBNNIEwHDCRSBUE3XHxcFVUWF3RaTwEoSVoAYwtBDkZUFBYhW0IAKElVVTUFR21yVEMldQl2VHgfXANvARRZR2dzEkU4dlF%2bGFQMYDMTbUNnAUEpDkZdfh5bSGcAFF1EX0ETcQ12VUsa; __jdv=122270672|baidu-pinzhuan|t_288551095_baidupinzhuan|cpc|0f3d30c8dba7459bb52f2eb5eba8ac7d_0_77fccaddbdbb4a66b3059a7ba081efbb|1538983651368; listck=73f612ad5033a6a19f1a8416fdf1f40d; _gcl_au=1.1.1766297181.1538983738; 3AB9D23F7A4B3C9B=4ZUMPHLUCE7S2WU4SDILXP727OKEJ524VKRGVI4CKTLSMVTLRDZUFRX42SVUGJZNGZ6SIK72572P62MQ4ELXOFJGPM; shshshfp=af5b549694a9e6cc33fa580f14a2b20f; __jda=122270672.1271793754.1533803093.1538983651.1538990706.11; shshshsID=2444292945815b8eb1fcaf889bed8d13_1_1538991083630; __jdb=122270672.4.1271793754|11.1538990706"

}

# Enable or disable spider middlewares
# See https://doc.scrapy.org/en/latest/topics/spider-middleware.html
SPIDER_MIDDLEWARES = {
   # 'JDCooker.middlewares.JdcookerSpiderMiddleware': 543,
    'scrapy_splash.SplashDeduplicateArgsMiddleware': 100,
}

# Enable or disable downloader middlewares
# See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html
DOWNLOADER_MIDDLEWARES = {
    # 'JDCooker.middlewares.JdcookerDownloaderMiddleware': 543,
    'scrapy_splash.SplashCookiesMiddleware': 723,
    'scrapy_splash.SplashMiddleware': 725,
    'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware': 810,

}

#设置去重过滤器
DUPEFILTER_CLASS = 'scrapy_splash.SplashAwareDupeFilter'
SPLASH_URL = 'http://localhost:8050/'
# Enable or disable extensions
# See https://doc.scrapy.org/en/latest/topics/extensions.html
# EXTENSIONS = {
#    'scrapy.extensions.telnet.TelnetConsole': None,
# }

# Configure item pipelines
# See https://doc.scrapy.org/en/latest/topics/item-pipeline.html
ITEM_PIPELINES = {
    'JDCooker.pipelines.JdcookerPipeline': 300,
}

# Enable and configure the AutoThrottle extension (disabled by default)
# See https://doc.scrapy.org/en/latest/topics/autothrottle.html
# AUTOTHROTTLE_ENABLED = True
# The initial download delay
# AUTOTHROTTLE_START_DELAY = 5
# The maximum download delay to be set in case of high latencies
# AUTOTHROTTLE_MAX_DELAY = 60
# The average number of requests Scrapy should be sending in parallel to
# each remote server
# AUTOTHROTTLE_TARGET_CONCURRENCY = 1.0
# Enable showing throttling stats for every response received:
# AUTOTHROTTLE_DEBUG = False

# Enable and configure HTTP caching (disabled by default)
# See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings
# HTTPCACHE_ENABLED = True
# HTTPCACHE_EXPIRATION_SECS = 0
# HTTPCACHE_DIR = 'httpcache'
# HTTPCACHE_IGNORE_HTTP_CODES = []
HTTPCACHE_STORAGE = 'scrapy_splash.SplashAwareFSCacheStorage'
